import { BooleanEnvEnum, NumberEnvEnum, StringEnvEnum } from "../constants/env";

export function getEnv(key: string): string | undefined {
  const value = process.env[key];
  return value;
}

export function getEnvString(key: StringEnvEnum): string {
  const value = getEnv(key);
  if (!value) {
    throw new Error(`Environment variable ${key} not found`);
  }
  return value;
}

export function getEnvNumber(key: NumberEnvEnum): number {
  const value = getEnv(key);
  if (!value) {
    throw new Error(`Environment variable ${key} not found`);
  }
  return Number(value);
}

export function getEnvBoolean(key: BooleanEnvEnum): boolean {
  const value = getEnv(key);
  if (!value) {
    throw new Error(`Environment variable ${key} not found`);
  }
  return value === 'true';
}

export function getEnvArray(key: string): string[] {
  const value = getEnv(key);
  if (!value) {
    throw new Error(`Environment variable ${key} not found`);
  }
  return value.split(',');
}


